﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Apex.Common.MVVM
{
    public class HierarchicalViewModel : INotifyPropertyChanged
    {
        private object _model;

        public object Model
        {
            get { return _model; }
            set { _model = value; OnPropertyChanged("Model"); }
        }

        public ObservableCollection<HierarchicalViewModel> Items { get; set; }

        #region INPC

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            if (string.IsNullOrEmpty(propertyName))
                throw new ArgumentException("Property name must not be null or empty.");

            if (PropertyChanged == null)
                return;

            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        #endregion
    }
}
